Skip to content

feat: withRetry helper#343

Merged
SilanHe merged 22 commits into
mainfrom
retryable-operation
May 1, 2026
Merged

feat: withRetry helper#343
SilanHe merged 22 commits into
mainfrom
retryable-operation

Conversation

@SilanHe

@SilanHe SilanHe commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Issue Link, if available

Fixes: #355

Description

Add a public WithRetry helper that retries any durable operation (waitForCallback, invoke, waitForCondition, etc.) end-to-end with configurable backoff. Today users have to hand-roll a while loop with manual context.wait() backoff calls. This helper provides a single, replay-safe, well-tested primitive for that pattern, reusing the exact same RetryStrategy shape developers already know from StepConfig.

New files:

  • withRetryConfig (sdk/.../config/) — Builder-pattern config holding the RetryStrategy (same type as StepConfig) and wrapInChildContext (defaults to true). If RetryStrategy is not specified a default RetryStrategy is used.

Key behaviors:

  • Reuses the existing RetryStrategy / RetryDecision types — zero new retry concepts.
  • Replay-safe by construction: every side-effect in the loop is a durable operation (operation.execute() calls durable primitives, context.wait() handles backoff).
  • Correctly propagates SuspendExecutionException and UnrecoverableDurableExecutionException without retrying — these are internal SDK control flow signals.
  • withRetry and withRetryAsync(context, name, operation, config)— wraps inrunInChildContext` by default for clean execution history grouping.

Demo/Screenshots

N/A

Checklist

  • I have filled out every section of the PR template
  • I have thoroughly tested this change

Testing

Unit Tests

yes

Integration Tests

yes

Examples

Yes.

yes

@SilanHe SilanHe changed the title feat: Retryable operation feat: withRetry helper Apr 27, 2026
@SilanHe SilanHe marked this pull request as ready for review April 27, 2026 18:53
@SilanHe SilanHe requested a review from a team April 27, 2026 18:53
Comment thread sdk/src/main/java/software/amazon/lambda/durable/util/WithRetryHelper.java Outdated
Comment thread sdk/src/main/java/software/amazon/lambda/durable/config/WithRetryConfig.java Outdated
Comment thread sdk/src/main/java/software/amazon/lambda/durable/util/WithRetryHelper.java Outdated
Comment thread sdk/src/main/java/software/amazon/lambda/durable/util/WithRetryHelper.java Outdated
@zhongkechen zhongkechen linked an issue Apr 29, 2026 that may be closed by this pull request
Comment thread sdk/src/main/java/software/amazon/lambda/durable/DurableContext.java Outdated
Comment thread sdk/src/main/java/software/amazon/lambda/durable/context/DurableContextImpl.java Outdated
Comment thread sdk/src/main/java/software/amazon/lambda/durable/context/DurableContextImpl.java Outdated
Comment thread sdk/src/main/java/software/amazon/lambda/durable/DurableContext.java Outdated
Comment thread sdk/src/main/java/software/amazon/lambda/durable/model/WithRetry.java Outdated
@SilanHe SilanHe requested a review from zhongkechen May 1, 2026 18:33
@SilanHe SilanHe merged commit c1455a8 into main May 1, 2026
11 checks passed
@SilanHe SilanHe deleted the retryable-operation branch May 1, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

withRetry

3 participants